package com.example.MyProject;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MyActivity extends Activity {
    public static final String PREFS_NAME = "MyPreferencesFile";
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final EditText name = (EditText)findViewById(R.id.editText1);
        final EditText mail = (EditText)findViewById(R.id.editText2);
        Button btn = (Button)findViewById(R.id.btnSavePreferences);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                SharedPreferences settings = getSharedPreferences(PREFS_NAME,0);
                SharedPreferences.Editor editor = settings.edit();
                editor.putString("name", name.getText().toString());
                editor.putString("email", mail.getText().toString());
                editor.commit();

                Intent intent = new Intent(getApplicationContext(), Second.class);
                startActivity(intent);

            }
        });


    }
}
